/*
 * @Date: 2022-04-11 14:03:23
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-04-21 12:59:05
 * @FilePath: \weibovue\src\api\blogs.ts
 * @Description: something
 */
export interface submitType {
  textarea: string;
  imageUrl?: string[];
}
import { request } from "../utils/request";
//创建博客
export const reqCreateBlog = (data: submitType) => {
  return request({
    url: "/blogs",
    method: "post",
    data,
  });
};
//获取用户博客列表
export const reqBlogList = (
  currentPage: number = 1,
  pageSize: number = 5,
  id?: number,
) => {
  if (id) {
    id = id;
  }
  return request({
    url: `/blogs/`,
    method: "get",
    params: {
      currentPage,
      pageSize,
      id,
    },
  });
};
//获取广场微博列表
export const reqSquraeBlogList = (
  currentPage: number = 1,
  pageSize: number = 5,
) => {
  return request({
    url: `/blogs/square`,
    method: "get",
    params: {
      currentPage,
      pageSize,
    },
  });
};
//删除博客
export const reqDeleteBlog = (id: number) => {
  return request({
    url: `/blogs/${id}`,
    method: "delete",
  });
};
//获取博客详情
export const reqBlogDetail = (blogId: number, userId: number) => {
  return request({
    url: `/blogs/detail/${blogId}/${userId}`,
    method: "get",
  });
};
//获取点赞数据
export const reqLikeData = (blogId: number) => {
  return request({
    url: `/blogs/like/${blogId}`,
    method: "get",
  });
};
